<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>案件回访</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="panel panel-default operation" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-tab">
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-card-body">
                                        <form class="layui-form" action="" lay-filter="info">
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab table_div">
                        <ul class="layui-tab-title" style="margin-left: 10px">
                            <li class="layui-this" id="unvisit">未访问</li>
                            <li id="visit">已访问</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--  未访问   -->
                            <div class="layui-tab-item layui-show">
                                <form class="layui-form" id="wfw_searchForm">
                                    <div class="layui-input-inline">
                                        <label for="wfw_jcajbh"></label>
                                        <input type="text" id="wfw_jcajbh" class="layui-input" autocomplete="off"
                                               placeholder="请输入案件编号">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="wfw_nsrsbh"></label>
                                        <input type="text" id="wfw_nsrsbh" class="layui-input" autocomplete="off"
                                               placeholder="请输入纳税人识别号">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="wfw_nsrmc"></label>
                                        <input type="text" id="wfw_nsrmc" class="layui-input" autocomplete="off"
                                               placeholder="请输入纳税人名称">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="wfw_jctzsrq"></label>
                                        <input type="text" readonly class="layui-input" id="wfw_jctzsrq"
                                               placeholder="检查通知书日期">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="wfw_zxwbrq"></label>
                                        <input type="text" readonly class="layui-input" id="wfw_zxwbrq"
                                               placeholder="执行完毕日期">
                                    </div>
                                    <div class="layui-input-inline" style="margin-left: 10px">
                                        <button type="button" class="layui-btn" id="wfw_search">查询</button>
                                        <button type="button" class="layui-btn" id="wfw_resetBtn">重置</button>
                                    </div>
                                </form>
                                <table class="layui-table" id="wfw_showTable" lay-filter="wfw_showTable"></table>
                            </div>
                            <!--  已访问   -->
                            <div class="layui-tab-item">
                                <form class="layui-form" id="yfw_searchForm">
                                    <div class="layui-input-inline">
                                        <label for="yfw_jcajbh"></label>
                                        <input type="text" id="yfw_jcajbh" class="layui-input" autocomplete="off"
                                               placeholder="请输入案件编号">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="yfw_nsrsbh"></label>
                                        <input type="text" id="yfw_nsrsbh" class="layui-input" autocomplete="off"
                                               placeholder="请输入纳税人识别号">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="yfw_nsrmc"></label>
                                        <input type="text" id="yfw_nsrmc" class="layui-input" autocomplete="off"
                                               placeholder="请输入纳税人名称">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="yfw_jctzsrq"></label>
                                        <input type="text" readonly class="layui-input" id="yfw_jctzsrq"
                                               placeholder="检查通知书日期">
                                    </div>
                                    <div class="layui-input-inline">
                                        <label for="yfw_zxwbrq"></label>
                                        <input type="text" readonly class="layui-input" id="yfw_zxwbrq"
                                               placeholder="执行完毕日期">
                                    </div>
                                    <div class="layui-input-inline" style="margin-left: 10px">
                                        <button type="button" class="layui-btn" id="yfw_search">查询</button>
                                        <button type="button" class="layui-btn" id="yfw_resetBtn">重置</button>
                                    </div>
                                </form>
                                <table class="layui-table" id="yfw_showTable" lay-filter="yfw_showTable"></table>
                            </div>
                        </div>
                    </div>
                    <!--填写内容-->
                    <div id="visitDiv" class="demo-transfer" style="display: none">
                        <div class="layui-form">
                            <div class="layui-form-item" style="margin-top: 5px">
                                <label class="layui-form-label" style="">填写内容</label>
                                <div class="layui-input-block">
                                    <label for="visitContent"></label>
                                    <textarea rows="2" name="visitContent" id="visitContent"
                                              placeholder="请输入回访内容,1-500个字符" autocomplete="off"
                                              class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-xs" lay-event="visit">回访</a>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var yfw_showTable;
    var wfw_showTable;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var inspectionMan = "";
    var mold = "";
    var contentdate = null;
    let wfw_zxwbrq_startTime = null;
    let wfw_zxwbrq_endTime = null;
    let wfw_jctzsrq_startTime = null;
    let wfw_jctzsrq_endTime = null;
    let yfw_zxwbrq_startTime = null;
    let yfw_zxwbrq_endTime = null;
    let yfw_jctzsrq_startTime = null;
    let yfw_jctzsrq_endTime = null;

    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        // 未回访
        wfw_showTable = table.render({
            elem: '#wfw_showTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/visit/list' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 100,
                    field: 'jcajxxuuid',
                    title: 'jcajxxuuid',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 205,
                    field: 'jcajbh',
                    title: '稽查案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 210,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 280,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'jtzfrq',
                    title: '检查通知书销号日期',
                    sort: true, templet: function (d) {
                        if (!d.jtzfrq) {
                            return '';
                        }
                        return layui.util.toDateString(d.jtzfrq, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 200,
                    field: 'zxwbrq',
                    title: '执行完毕日期',
                    sort: true, templet: function (d) {
                        if (!d.zxwbrq) {
                            return '';
                        }
                        return layui.util.toDateString(d.zxwbrq, 'yyyy-MM-dd');
                    }
                }, {
                    fixed: 'right',
                    align: 'center',
                    width: 100,
                    toolbar: "#tool",
                    title: '操作'
                },
            ]],
            toolbar: '#logToolbar'
        });
        // 列操作
        table.on('tool(wfw_showTable)', function (obj) {
            const data = obj.data;
            switch (obj.event) {
                case 'visit':
                    const _jcajxxuuid = data.jcajxxuuid;
                    layer.open({
                        type: 1,
                        offset: '50px',
                        skin: 'layui-layer-molv',
                        title: "回访内容",
                        area: ['700px', '320px'],
                        shade: 0,
                        shadeClose: false,
                        content: jQuery("#visitDiv"),
                        btn: ['确认', '取消'],
                        yes: function (index) {
                            var visitContent = $('#visitContent').val();
                            if (CoreUtil.isEmpty(visitContent)) {
                                layer.msg("回访内容没有填写!");
                                return false;
                            }

                            var mapArr = {
                                'jcajxxuuid': _jcajxxuuid,
                                'bz': visitContent,
                            };

                            CoreUtil.sendPost("/workflow/visit/visit", mapArr,
                                function (res) {
                                    if (res.code === 0) {
                                        layer.msg("成功 ！");
                                        wfw_search();
                                        yfw_search();
                                        return false;
                                    } else {
                                        layer.msg(res.msg);
                                        return false;
                                    }
                                });
                            layer.close(index);
                        }
                    });
                    break;
            }
        });
        // 列操作
        table.on('tool(yfw_showTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });
        // 已回访
        yfw_showTable = table.render({
            elem: '#yfw_showTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/visit/list1' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 100,
                    field: 'jcajxxuuid',
                    title: 'jcajxxuuid',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 180,
                    field: 'bz',
                    title: '回访结果',
                    sort: true,
                }, {
                    align: 'center',
                    width: 205,
                    field: 'jcajbh',
                    title: '稽查案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 210,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 280,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'jtzfrq',
                    title: '检查通知书销号日期',
                    sort: true, templet: function (d) {
                        if (!d.jtzfrq) {
                            return '';
                        }
                        return layui.util.toDateString(d.jtzfrq, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 200,
                    field: 'zxwbrq',
                    title: '执行完毕日期',
                    sort: true, templet: function (d) {
                        if (!d.zxwbrq) {
                            return '';
                        }
                        return layui.util.toDateString(d.zxwbrq, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 200,
                    field: 'ajhfrq',
                    title: '案件回访日期',
                    sort: true, templet: function (d) {
                        if (!d.ajhfrq) {
                            return '';
                        }
                        return layui.util.toDateString(d.ajhfrq, 'yyyy-MM-dd');
                    }
                }
            ]],
            toolbar: '#logToolbar'
        });
        // 列操作
        table.on('tool(yfw_showTable)', function (obj) {
            const data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });
        // 列操作
        table.on('tool(yfw_showTable)', function (obj) {
            const data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });
        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });
        //未访问-执行完毕日期
        laydate.render({
            elem: '#wfw_zxwbrq'
            , type: 'date'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    wfw_zxwbrq_startTime = value.split("~")[0];
                    wfw_zxwbrq_endTime = value.split("~")[1];
                } else {
                    wfw_zxwbrq_startTime = null;
                    wfw_zxwbrq_endTime = null;
                }
            }
        });
        //未访问-检查通知书日期
        laydate.render({
            elem: '#wfw_jctzsrq'
            , type: 'date'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    wfw_jctzsrq_startTime = value.split("~")[0];
                    wfw_jctzsrq_endTime = value.split("~")[1];
                } else {
                    wfw_jctzsrq_startTime = null;
                    wfw_jctzsrq_endTime = null;
                }
            }
        });
        //已访问-执行完毕日期
        laydate.render({
            elem: '#yfw_zxwbrq'
            , type: 'date'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    yfw_zxwbrq_startTime = value.split("~")[0];
                    yfw_zxwbrq_endTime = value.split("~")[1];
                } else {
                    yfw_zxwbrq_startTime = null;
                    yfw_zxwbrq_endTime = null;
                }
            }
        });
        //已访问-检查通知书日期
        laydate.render({
            elem: '#yfw_jctzsrq'
            , type: 'date'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    yfw_jctzsrq_startTime = value.split("~")[0];
                    yfw_jctzsrq_endTime = value.split("~")[1];
                } else {
                    yfw_jctzsrq_startTime = null;
                    yfw_jctzsrq_endTime = null;
                }
            }
        });
        //未访问查询
        $('#wfw_search').on('click', function () {
            wfw_search();
        });
        //以访问查询
        $('#yfw_search').on('click', function () {
            yfw_search();
        });

    });

    function wfw_search() {
        const whereParams = {
            "jcajbh": $("#wfw_jcajbh").val(),
            "nsrsbh": $("#wfw_nsrsbh").val(),
            "nsrmc": $("#wfw_nsrmc").val(),
            "wfw_jctzsrq_startTime": wfw_jctzsrq_startTime,
            "wfw_jctzsrq_endTime": wfw_jctzsrq_endTime,
            "wfw_zxwbrq_startTime": wfw_zxwbrq_startTime,
            "wfw_zxwbrq_endTime": wfw_zxwbrq_endTime
        };
        wfw_showTable.reload({
            contentType: 'application/json'
            , headers: {"authorization": token}
            , where: whereParams
            , url: '/workflow/visit/list' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }, page: {
                curr: 1 //重新从第 1 页开始
            }
        }, false);
    }

    function yfw_search() {
        const whereParams = {
            "jcajbh": $("#yfw_jcajbh").val(),
            "nsrsbh": $("#yfw_nsrsbh").val(),
            "nsrmc": $("#yfw_nsrmc").val(),
            "yfw_jctzsrq_startTime": yfw_jctzsrq_startTime,
            "yfw_jctzsrq_endTime": yfw_jctzsrq_endTime,
            "yfw_zxwbrq_startTime": yfw_zxwbrq_startTime,
            "yfw_zxwbrq_endTime": yfw_zxwbrq_endTime
        };
        yfw_showTable.reload({
            contentType: 'application/json'
            , headers: {"authorization": token}
            , where: whereParams
            , url: '/workflow/visit/list1' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }, page: {
                curr: 1 //重新从第 1 页开始
            }
        }, false);
    }

    function view(data, id) {
        var _id = data.jcajxxuuid;
        $("#_jcajxxuuid").val(data.jcajxxuuid);
        var stateCode = data.stateCode;
        $(".title").html("案件编号：" + data.jcajbh);
        $("#ajmc").val(data.ajmc);
        $("#jcxm").val(data.jcxm);
        $("#nsrmc").val(data.nsrmc);
        $("#nsrsbh").val(data.nsrsbh);
        $("#jcry").val(data.jcry);
        $("#details").val(data.details);

        var _fjdz = data.fjdz;
        if (!CoreUtil.isEmpty(_fjdz)) {
            $("#fjdz").val(_fjdz);
            var fjdzArr = _fjdz.split(",");
            var tmp = "<table class='layui-table'><tbody>";
            for (var i = 0; i < fjdzArr.length; i++) {
                var _fjdz = '"' + fjdzArr[i] + '"';
                var _i = i + 1;
                tmp += "<tr><td>附件" + _i + "</td><td>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjyl("
                    + _fjdz + ")'>一键预览</a>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjfz("
                    + _fjdz + ")'>一键复制</a>" + "</td></tr>";
            }
            tmp += "</tbody></table>";
            $("#fjdzDiv").html(tmp);
        } else {
            $("#fjdzDiv").html("未传附件");
        }
        // 查询办理流程
        // activityRecordDiv(data.jcajxxuuid);
        $("#pushHearMan21").hide();

        $(".table_div").hide();
        $(".operation").show();

        if (CoreUtil.isEmpty(_id)) {
            $("#fileInfoDiv").hide();
        } else {
            $("#fileInfoDiv").show();
        }

    }

    function visit(_id) {
        var mapArr = {
            'riskvisit': '1',
            'id': _id
        };
        CoreUtil.sendPost("/workflow/visit/visit", mapArr,
            function (res) {
                if (res.code === 0) {
                    layer.msg("已读成功！");
                    return false;
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });

    }

    function back() {
        wfw_search();
        $(".table_div").show();
        $(".operation").hide();
    }

    $("#unvisit").click(function () {
        wfw_search();
    });
    $("#visit").click(function () {
        yfw_search();
    });
</script>

</body>
</html>